
<h1>Edit this list</h1>

<h2><%= link_to "<< Back to My Lists", :action => :index %></h2>
<h2><%= @list.name %> </h2>

<script lanuage="javascript">
function deleteItem(item_id) {
	// alert("Setup to delete: " + something);	
	document.deleteForm.list_id.value = <%= @list.id %>;
	document.deleteForm.item_id.value = item_id;
	document.deleteForm.submit();
}
</script>

<form name="deleteForm" action="/list/item_edit" method="post">
	<input type="hidden" name="item_id" value=""/>
	<input type="hidden" name="list_id" value=""/>
</form>

<h4>Existing Items:</h4>
<%if @items.length > 0 %>
  <% form_for :edit, :url => { :action => :edit_list_item } do |form| %>
    <p>Title:<p>
    <div><%= text_field("list", "name", "size" => 40) %></div> <!-- "value" => @list.name -->    
    <ul class="list_items">Items:
	    <% for item in @items -%>
	      <li>
		      <input type="text" size="40" value="<%= item.content %>"><!-- <%= form.text_field :content, "size" => 40 %> -->
		
		<%= image_tag("/images/grey_delete.gif", :class => "close_image", :size => "11x11", :onclick => "deleteItem(#{item.id})") %>
			
	
		    </li>
	    <% end %>
    </ul>
    <div>
	    <span><%= submit_tag 'Save this list' %></span><span class="cancel"><%= link_to "Cancel", :action => :show, :id => @list.id %></span>
	  </div>
  <% end %>
<% else %>
  There are no list items for this list.
<% end %>


<% if flash[:notice] -%>
  <div id="notice"><%= flash[:notice] %></div>
<% end -%>

